unit TimeFormat;

interface

type
  TTimeFormat = class(TObject)
  public
    class function FormatMinutes(const AMinutes: Integer): String;
    class function FormatSeconds(const ASeconds: Integer): String;
  end;

implementation

uses
  SysUtils;

{ TTimeFormat }

class function TTimeFormat.FormatMinutes(const AMinutes: Integer): String;
begin
  Result := FormatSeconds(AMinutes * 60);
end;

class function TTimeFormat.FormatSeconds(const ASeconds: Integer): String;
var
  Hours, Minutes, Seconds: Integer;
  FormatString: String;
begin
  Hours := ASeconds div 3600;
  Minutes := (ASeconds - (Hours * 3600)) div 60;
  Seconds := ASeconds - ((Hours * 3600) + (Minutes * 60));
  if Hours = 0 then
    FormatString := '%1:.2d:%2:.2d min'
  else
    FormatString := '%0:d:%1:.2d:%2:.2d h';
  Result := Format(FormatString, [Hours, Minutes, Seconds]);
end;

end.
